package com.project.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.CustomerBean;
import com.project.mapper.ICustomerMapper;
import com.project.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImp implements ICustomerService {
    @Autowired
    private ICustomerMapper mapper;//
    @Override
    public List<CustomerBean> findAll() {
        return  mapper.findByItem(null, null);
    }
    @Override
    public PageInfo<CustomerBean> findByItem(int pageNO, String name, String scope) {
        PageHelper.startPage(pageNO, PAGESIZE);
        PageInfo<CustomerBean> pageInfo=PageInfo.of(mapper.findByItem(name, scope));
        return pageInfo;
    }

    @Override
    public void add(CustomerBean customer) {
        mapper.add(customer);

    }

    @Override
    public void update(int id, String headMan, String tel, String scope) {
        mapper.update(id, headMan, tel, scope);
    }

    @Override
    public CustomerBean findById(int id) {
        return mapper.findById(id);
    }
}
